package com.bean;

import java.util.Objects;

public class Student {
    private Integer id;

    private String no;

    private String name;

    private Integer age;

    private String sex;

    private String email;

    private String phone;

    private Integer classId;

    private String className;

    private String headPic;

    private String password;

    public Student() {
    }

    public Student(String no, String password) {
        this.no = no;
        this.password = password;
    }

    public Student(String no, String name, Integer age, Integer sex, String email, String phone, Integer classId, String headPic, String password) {
        this.no = no;
        this.name = name;
        this.age = age;
        this.sex = (sex == 0 ? "男" : "女");
        this.email = email;
        this.phone = phone;
        this.classId = classId;
        this.headPic = headPic;
        this.password = password;
    }

    @Override
    public String toString() {
        return "Student{" +
                "id=" + id +
                ", no='" + no + '\'' +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", sex='" + sex + '\'' +
                ", email='" + email + '\'' +
                ", phone='" + phone + '\'' +
                ", classId=" + classId +
                ", className='" + className + '\'' +
                ", headPic='" + headPic + '\'' +
                ", password='" + password + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Student student = (Student) o;
        return Objects.equals(no, student.no) &&
                Objects.equals(password, student.password);
    }

    @Override
    public int hashCode() {

        return Objects.hash(no, password);
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getNo() {
        return no;
    }

    public void setNo(String no) {
        this.no = no;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public Integer getClassId() {
        return classId;
    }

    public void setClassId(Integer classId) {
        this.classId = classId;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getClassName() {
        return className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    public Integer getSex() {
        Integer sexInt = null;
        if (sex == "男") {
            sexInt = 0;
        } else if (sex == "女") {
            sexInt = 1;
        }
        return sexInt;
    }

    public void setSex(Integer sex) {
        if (sex == null) {
            this.sex = null;
        } else if (sex == 1) {
            this.sex = "女";
        }else{
            this.sex = "男";
        }
    }

    public String getHeadPic() {
        return headPic;
    }

    public void setHeadPic(String headPic) {
        this.headPic = headPic;
    }
}